<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
        xmlns:c="http://java.sun.com/jstl/core" 
        xmlns:p="http://primefaces.org/ui"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        
        >

    <ui:composition template="template.xhtml">
        <ui:define name="content">

<div id="body">
        <div class="panel">

            <h2>Shopping Cart</h2>

            <h:messages layout="table" styleClass="error" />

            
            <h:panelGroup rendered="#{empty cart}">
                <p><b>The Shopping Cart is empty</b></p>
            </h:panelGroup>
            
            <h:panelGroup rendered="#{!empty cart}">
                <h:form>
                        
                        <p:dataTable value="#{cart.cartItems}" var="cartItem">
                            <p:column>
                                <h:outputText value="#{cartItem.item.product.name}"/>
                                <br/>
                                <p:commandLink action="#{catalog.doFindItem}">
                                    <h:outputText value="#{cartItem.item.name}"/>
                                    <f:param name="itemId" value="#{cartItem.item.id}"/>
                                </p:commandLink>
                            </p:column>
                            <p:column>
                                <p:commandLink action="#{cart.updateQuantity}">
                                    <h:outputText value="Update"/>
                                    <f:param name="itemId" value="#{cartItem.item.id}"/>
                                </p:commandLink>
                            </p:column>
                            <p:column>
                                <h:inputText value="#{cartItem.quantity}"/>
                            </p:column>
                            <p:column>
                                x
                                <h:outputText value="#{cartItem.item.unitCost}"/> $
                            </p:column>
                            <p:column>
                                = <h:outputText value="#{cartItem.subTotal}"/> $
                            </p:column>
                            <p:column>
                                
                                <p:commandLink action="#{cart.removeItemFromCart}">
                                    <h:outputText value="Remove"/>
                                    <f:param name="itemId" value="#{cartItem.item.id}"/>
                                </p:commandLink>
                            </p:column>
                        </p:dataTable>

                        <br/>

                        <div class="zoneButton">
                            Total $
                            <h:outputText value="#{cart.total}"/>

                            
                            <p:commandLink action="#{cart.checkout}">
                                <h:outputText value="Check Out"/>
                            </p:commandLink>
                        </div>
                    </h:form>
                
            </h:panelGroup>
            
            


        </div>
    </div>            
            
            

            
</ui:define>
	
        
    </ui:composition>
</html>